package com.oig.sys.log.dto;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.oig.common.validator.GroupAdd;
import io.swagger.v3.oas.annotations.media.Schema;

import lombok.Data;
import org.springframework.format.annotation.DateTimeFormat;

import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.NotNull;
import java.util.Date;

@Schema
@Data
public class SysAuditLogDto {

	@Schema(description = "跟踪号")
	private String traceId;

	@Schema(description = "表名", requiredMode = Schema.RequiredMode.NOT_REQUIRED)
	@NotEmpty(message = "参数错误,表名不能为空", groups= GroupAdd.class)
	private String tableName;
	@Schema(description = "记录id", requiredMode = Schema.RequiredMode.NOT_REQUIRED)
	@NotEmpty(message = "参数错误,记录id不能为空", groups= GroupAdd.class)
	private String tableId;
	@Schema(description = "操作", requiredMode = Schema.RequiredMode.NOT_REQUIRED)
	@NotEmpty(message = "参数错误,操作不能为空", groups= GroupAdd.class)
	private String operation;
	@Schema(description = "改动后列值")
	private String newValue;
	@Schema(description = "改动列及原值")
	private String oldValue;

	@Schema(description = "改动时间", requiredMode = Schema.RequiredMode.NOT_REQUIRED)
	@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
	@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
	@NotNull(message = "参数错误,操作时间不能为空", groups= GroupAdd.class)
	private Date createTime;

	@Schema(description = "改动时间 查询时间范围")
	@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
	@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
	private Date startCreateTime;

	@Schema(description = "改动时间 查询时间范围")
	@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
	@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
	private Date endCreateTime;

	@Schema(description = "操作用户id")
	private Integer userId;
	@Schema(description = "操作用户")
	private String userName;
	@Schema(description = "操作用户所属租户id")
	private Integer tenantId;
	@Schema(description = "操作用户所属租户名称")
	private String tenantName;
}
